import { getMaterialCodeList as getBaseGoodsList } from "@/api/process/mesProcessMaterial";
import { getBomVersionNumberList } from "@/api/order/mesProdOrder";
export const baseGoodsDialog2 = {
  data () {
    return {
      initForm: { orderCode: 1 },
      baseGoodsDialogVisible2: false, //表格弹框隐藏显示
      getBaseGoodsList, // 获取弹框数据接口
      hasBaseGoodsFooter: true, // 是否需要底部按钮默认true
      baseGoodsSearchDialog2: {
        inline: true,
        formDesc: {
          goodsCode: {
            type: "input",
            layout: 8,
            label: $i18n.t('common.materialCode'),
          },
          goodsName: {
            type: "input",
            layout: 8,
            label: $i18n.t('common.materialName'),
          },
        },
      },
      baseGoodsDialogColumn2: [
        {
          type: "selection",
          fixed: "left",
        },
        {
          type: "index",
          label: $i18n.t("common.order"),
          width: 60,
          fixed: "left",
        },
        // {
        //   prop: "erpMaterialId",
        //   label: "erp物料id",
        // },
        {
          prop: "goodsCode",
          label: $i18n.t("mesProdOrder.goodsCode"),
          width: 180,
          showOverflowTooltip: true,
          fixed: "left",
        },
        {
          prop: "goodsName",
          label: $i18n.t("mesProdOrder.goodsName"),
          width: 180,
          showOverflowTooltip: true,
        },
        {
          prop: "goodsDesc",
          label: $i18n.t("mesProdOrder.goodsDesc"),
          width: 180,
          showOverflowTooltip: true,
        },
        {
          prop: "yardsSixNine",
          label: $i18n.t("mesProdOrder.yardsSixNine"),
          width: 150,
          showOverflowTooltip: true,
        },
        {
          prop: "seriesCode",
          label: $i18n.t("mesProdOrder.seriesCode"),
          width: 120,
          showOverflowTooltip: true,
        },
        {
          prop: "seriesName",
          label: $i18n.t("mesProdOrder.seriesName"),
          width: 180,
          showOverflowTooltip: true,
        },

        {
          prop: "unit",
          label: $i18n.t("mesProdOrder.unit"),
          width: 150,
          showOverflowTooltip: true,
        },
        {
          prop: "specification",
          label: $i18n.t("mesProdOrder.specification"),
          width: 150,
          showOverflowTooltip: true,
        },
        {
          prop: "gbCode",
          label: $i18n.t("mesProdOrder.gbCode"),
          width: 150,
          showOverflowTooltip: true,
        },
      ],
    };
  },
  methods: {
    // 弹框表格，双击表格，或者点击确定 返回选中数据
    async getSelectBaseGoods2 ([data]) {
      // 调试完成记得删除控制台打印
      // console.log("选中数据2222----", data);
      // 这里可以自定义返回字段信息
      // 第一个入参为当前表单绑定的对象，第二个入参为要修改的字段名，第三个入参为选中数据中相应信息
      if (this.formDataDialog.prodCode !== data.goodsCode) {
        this.$set(this.formDataDialog, "bomVersionNumber", "");
      }
      this.$set(this.formDataDialog, "prodCode", data.goodsCode);
      this.$set(this.formDataDialog, "prodName", data.goodsName);
      this.$set(this.formDataDialog, "seriesCode", data.seriesCode);
      this.$set(this.formDataDialog, "seriesName", data.seriesName);
      this.$set(this.formDataDialog, "measureUnits", data.unit); //单位
    },
  },
};
